/*
 * 作者：姚俊
 * 功能：查询所有，产生Excel文件的action
 * 日期：2015-05-22
 */
package admin.action.baseInfo;


import teacher.bean.Award;
import teacher.bean.Paper;
import teacher.bean.Patent;
import teacher.bean.Project;
import teacher.bean.Treatise;
import tools.StringDate;

import admin.databaseToExcel.PullAwardToExcel;
import admin.databaseToExcel.PullPaperToExcel;
import admin.databaseToExcel.PullPatentToExcel;
import admin.databaseToExcel.PullPorjectToExcel;
import admin.databaseToExcel.PullTeacherToExcel;
import admin.databaseToExcel.PullTreatiseToExcel;


public class FileCreateAction {
	
	
	private String date1;
	private String date2;
	private String name;
	private int flag;
		
	public String getDate1() {
		return date1;
	}

	public void setDate1(String date1) {
		this.date1 = date1;
	}

	public String getDate2() {
		return date2;
	}

	public void setDate2(String date2) {
		this.date2 = date2;
	}

		public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
		public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}
	

		/**
		 * @category 默认方法，生成老师信息的报表
		 * @author yaojun
		 */
		public String execute()
		{
			PullTeacherToExcel.teacherExcel();
			return "succ";
		}
		
		/**
		 * @category 生成论文报表
		 * @author yaojun
		 */
		public String paper()
		{

			if(this.getFlag()==0)
			{
				PullPaperToExcel.paperExcel(0,null,null,0);
			}
			else if(this.getFlag()==1)
			{
				Paper paper1=new Paper();
				paper1.setDate(StringDate.StringToDate(this.getDate1()));
				Paper paper2=new Paper();
				paper2.setDate(StringDate.StringToDate(this.getDate2()));
				PullPaperToExcel.paperExcel(1,paper1,paper2,0);
			}
			else if(this.getFlag()==2)
			{
				if(this.getName().equals(""))
				{
					PullPaperToExcel.paperExcel(0,null,null,0);
				}
				else
				{
					Paper paper=new Paper();
					paper.setName(this.getName());
					PullPaperToExcel.paperExcel(2,paper,null,0);
				}
	
			}
			return "succ";
		}
		
		/**
		 * @category 生成专利的报表
		 * @author yaojun
		 */
		public String patent()
		{
			
			if(this.getFlag()==0)
			{
				PullPatentToExcel.patentExcel(0,null,null,0);
			}
			else if(this.getFlag()==1)
			{
				Patent patent1=new Patent();
				patent1.setEmpowerDate(StringDate.StringToDate(this.getDate1()));
				Patent patent2=new Patent();
				patent2.setEmpowerDate(StringDate.StringToDate(this.getDate2()));
				PullPatentToExcel.patentExcel(1,patent1,patent2,0);
			}
			else if(this.getFlag()==2)
			{
				if(this.getName().equals(""))
				{
					PullPatentToExcel.patentExcel(0,null,null,0);
				}
				else
				{
					Patent patent=new Patent();
					patent.setName(this.getName());
					PullPatentToExcel.patentExcel(2,patent,null,0);
				}
				
				
				
			}
			return "succ";
		}
		
		/**
		 * @category 生成项目的报表
		 * @author yaojun
		 */
		public String project()
		{
			if(this.getFlag()==0)
			{
				PullPorjectToExcel.projectExcel(0,null,0);
			}
			else if(this.getFlag()==1)
			{
				Project project=new Project();
				project.setBeginDate(StringDate.StringToDate(this.getDate1()));
				project.setFinishDate(StringDate.StringToDate(this.getDate2()));
				PullPorjectToExcel.projectExcel(1,project,0);
			}
			else if(this.getFlag()==2)
			{
				if(this.getName().equals(""))
				{
					PullPorjectToExcel.projectExcel(0,null,0);
				}
				else
				{
					Project project=new Project();
					project.setName(this.getName());
					PullPorjectToExcel.projectExcel(2,project,0);
				}

			}
			return "succ";
		}
		
		/**
		 * @category 生成获奖的报表
		 * @author yaojun
		 */
		public String award()
		{
			
			if(this.getFlag()==0)
			{
				System.out.println("flag="+flag);
				PullAwardToExcel.awardExcel(0,null,null,0);
			}
			else if(this.getFlag()==1)
			{
				System.out.println("flag="+flag);
				Award award1=new Award();
				award1.setDate(StringDate.StringToDate(this.getDate1()));
				Award award2=new Award();
				award2.setDate(StringDate.StringToDate(this.getDate2()));
				PullAwardToExcel.awardExcel(1,award1,award2,0);
				System.out.println("date1="+StringDate.StringToDate(this.getDate1()));
				System.out.println("date2="+StringDate.StringToDate(this.getDate2()));
			}
			else if(this.getFlag()==2)
			{
				if(this.getName().equals(""))
				{
					PullAwardToExcel.awardExcel(0,null,null,0);
				}
				else
				{
					
					Award award=new Award();
					award.setName(this.getName());
					System.out.println("name="+this.getName());
					PullAwardToExcel.awardExcel(2,award,null,0);
					
				}
				
				System.out.println("flag="+flag);				
			}
			return "succ";
		}
		
		/**
		 * @category 生成专著的报表
		 * @author yaojun
		 */
		public String treatise()
		{
			
			if(this.getFlag()==0)
			{
				PullTreatiseToExcel.treatiseExcel(0,null,null,0);
			}
			else if(this.getFlag()==1)
			{
				Treatise treatise1=new Treatise();
				treatise1.setDate(StringDate.StringToDate(this.getDate1()));
				Treatise treatise2=new Treatise();
				treatise2.setDate(StringDate.StringToDate(this.getDate2()));
				PullTreatiseToExcel.treatiseExcel(1,treatise1,treatise2,0);
			}
			else if(this.getFlag()==2)
			{
				if(this.getName().equals(""))
				{
					PullTreatiseToExcel.treatiseExcel(0,null,null,0);
				}
				else
				{
					Treatise treatise=new Treatise();
					treatise.setName(this.getName());
					PullTreatiseToExcel.treatiseExcel(2,treatise,null,0);
				}
				
			}
			return "succ";
		}

}
